<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 用循环求自然数1到n的平方和。
        // 分析：sum=1*1+2*2+...+n*n
        var add = 0
        var num = prompt(`你想求1-几的平方和`)
        for(var i = 1; i <= num; i++) {
            sum = i * i
            add += sum
        }
        console.log(add);
    </script>
</head>
<body>
    
</body>
</html>